package Client.GUI.Popups;

import Client.Net.*;
import java.awt.*;
import javax.swing.*;

/**
 *
 */
public abstract class AbstractPopup extends JPanel
{
   protected IPopupContainer m_Container;
   protected ICommunication m_Communication;
   public AbstractPopup(ICommunication communication, IPopupContainer container)
   {
       super();
       m_Communication = communication;
       m_Container = container;
   }
   
   public void showPopup(Container c)
   {
       Dimension D = getPreferredSize();
       int cWdt = c.getWidth() / 2;
       int cHgt = c.getHeight() / 2;
       c.add(this);
       setLocation(cWdt - (((int)getPreferredSize().getWidth()) / 2), cHgt - (((int)getPreferredSize().getHeight()) / 2));
       setSize(getPreferredSize());
       register();     
       setVisible(true);
   }
   
   protected void register()
   {
   }
   
   protected void unregister()
   {
   }
   
   public void dispose()
   {
       unregister();
       setVisible(false);
       if (getParent() != null)
	   getParent().remove(this);
   }
}
